package com.bstek.uflo.form.view.process;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.data.provider.Page;
import com.bstek.uflo.model.ProcessDefinition;
import com.bstek.uflo.query.ProcessQuery;
import com.bstek.uflo.service.ProcessService;

/**
 * @author Jacky.gao
 * @since 2013年11月18日
 */
@Component("uflo.form.processList")
public class ProcessList {
	@Autowired
	@Qualifier(ProcessService.BEAN_ID)
	private ProcessService processService;
	
	@DataProvider
	public void loadProcesses(Page<ProcessDefinition> page){
		ProcessQuery query=processService.createProcessQuery();
		query.addOrderDesc("createDate");
		query.page(page.getPageSize()*(page.getPageNo()-1), page.getPageSize());
		page.setEntities(query.list());
		page.setEntityCount(query.count());
	}
}
